<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed'); ?>

<div class="middle padtop10 myclear">
	<div class="page-content">
			<!-- bread crumb -->
			<p id="bread-crumb">
				<a href="<?php echo site_url();?>">
					<?php echo $lang['home']?>
				</a>
				<?php echo $lang['list_tran_miss']?>
			</p><!-- end bread crumb -->
			
			<table width="100%" class="marbottom10"  border="0" cellpadding="0" cellspacing="0">
				<tr>
					<td width="50%">
						<h2 class="title text-666">
							<?php echo $lang['list_tran_miss'];?>
						</h2>
					</td>
				</tr>
			</table>
			<div style="text-align:right">
				<input type="button" value="Check Soha Payment" onclick="checkOrderStatus();" />
			</div>
			<table class="martop5 tbl-list tb-pad5" width="100%" cellpadding="0" cellspacing="0" border="1">
				<tr>
					<td width="13%" class="td-label text-666 bold">
						<span class="padleft3">
							<?php echo $lang['date']?>
						</span>
					</td>
					
					<td width="13%" class="td-label text-666 bold">
						<span class="padright3"><?php echo $lang['transaction_code']?></span>
					</td>
					
					<td width="20%" class="td-label bold text-666">
						<span class="padleft3"><?php echo $lang['content']?></span>
					</td>
					
					<td width="20%" class="td-label bold text-666" width="80">
						<span class="padleft3"><?php echo $lang['payment_type']?></span>
					</td>
					
					<td width="13%" class="td-label bold text-666 text-right">
						<span class="padright3"><?php echo $lang['recharge_money']?></span>
					</td>
					
					<td width="13%" class="td-label bold text-666 text-right">
						<span class="padright3"><?php echo $lang['account_balance']?></span>
					</td>
					
					<td class="td-label bold text-666 text-right">
						<span class="padright3"><?php echo $lang['status']?></span>
					</td>
				</tr>
				
				<?php 
				$totalMoney = 0;
				foreach($items as $paid)
				{
					$totalMoney += $paid['money'];
				?>
				
				<tr>
					<td>
						<?php echo $paid['payment_time'];?>
					</td>
					
					<td>
						<a href="<?php echo site_url('logs/check_soha/?code='.$paid['payment_key']);?>" target="_blank" title="Check Soha">
							<?php echo $paid['payment_key'];?>
						</a>
					</td>
					
					<td>
						<?php echo str_replace(", ","<br />",$paid['message']);?>
					</td>
					
					<td>
						<?php echo $paid['typepay'];?>
					</td>
					
					<td style="text-align:right">
						<?php if($paid['type'] == 0) echo '+'.number_format($paid['money']);?>
					</td>
					
					<td style="text-align:right">
						<?php echo number_format($paid['currentbalance']);?>
					</td>
					
					<td style="text-align:center" class="view_<?php echo $paid['payment_key'];?>">
						<input type="hidden" name="key_items[]" value="<?php echo $paid['payment_key'];?>" />
					</td>
				</tr>
				
				<?php }?>
				
			</table>
			
			<!-- paging -->
			<div class="myclear martop20">
				<div class="brv-paging-left">
					<table class="tbl-list brv-paging" border="1">
						<tr>
							<td class="brv-paging-name">
								<?php echo 'Trang '. $page.' ['.$totalPage.']'?>
							</td>
							
							<td class="brv-paging-pre-next">
								<img class="brv-img-pre" alt="previous" src="/images/imgpre.gif" onclick="goPage(<?php echo $page > 1 ? $page - 1 : $page;?>)" />
								<img class="brv-img-next" alt="next" src="/images/imgnext.gif" onclick="goPage(<?php echo $page < $totalPage ? $page + 1 : $page;?>)" />
							</td>
						</tr>
					</table>
				</div>
				<!-- important. fix for ie 6. Don't remove -->
				<!--[if IE 6]><br class="clearboth" /><![endif]-->
			</div>
			<!-- end paging -->
			
			<br /><br />
		</div> <!-- end colum right -->
		
		<div id="toannh-tooltip" >
			<p class="myclear">
				<img alt="" id="toannh-tooltip-arrow" src="/images/toannhtooltiparrow.gif" />
			</p>
			<div id="toannh-tooltip-inner" >
				<p id="toannh-tooltip-title"></p>
				<div id="toannh-tooltip-body" class="myclear"></div>
				<p class="ok-box myclear">
					<img alt="" src="/images/okbtn.gif" onclick="removeToannh_Tooltip();" />
				</p>
			</div>
		</div>
		
</div>
</div>

<script language="javascript">
<?php if($check){?>
$(document).ready(function(){
	checkOrderStatus();
});
<?php }?>
function goPage(strVal)
{
	window.location = '<?php echo site_url('budget/transactionMiss');?>/?page='+strVal;
}
function checkOrderStatus()
{
	var obj_code = $('input:hidden[name="key_items[]"]');
	var code = $(obj_code).val();
	if(code == '' || code == null || code == 'undefined') return;
	$('.view_'+code).html('<img src="/images/ajaxLoading.gif" border="0" />');
	$.ajax({
		url: '<?php echo site_url('budget/check_soha');?>/?code=' + code,
		success: function(data){
			if(data == '1') $('.view_'+code).html('<img src="/images/completed.png" border="0" title="Success" />');
			else $('.view_'+code).html('<img src="/images/imgwait.png" border="0" title="Waiting" />');
			checkOrderStatus();
		}
	});
}
</script>